#include "image.h"
#include "ui_image.h"
#include <QDebug>
#include <QDebug>
#include "include/hi_comm_isp.h"
#include "include/hi_awb_comm.h"
#include "include/mpi_awb.h"
#include "include/mpi_isp.h"
#include "include/mpi_ae.h"
#include "include/hi_awb_comm.h"
#include "include/mpi_awb.h"


ISP_WB_ATTR_S m_stWBAttr;
ISP_EXPOSURE_ATTR_S  m_stExpAttr;
//ISP_AE_ROUTE_S  m_stExpAttr;
ISP_WB_ATTR_S  wbattrs;
ISP_SHARPEN_ATTR_S pstIspShpAttr;

VI_PIPE pipe=0;


Image::Image(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Image)
{
    ui->setupUi(this);
   // HI_MPI_ISP_GetWBAttr(pipe, &wbattrs);
}

Image::~Image()
{
    delete ui;
}

void Image::on_horizontalSlider_3_valueChanged(int value)
{
    qDebug()<<"shard"<<value;
    HI_MPI_ISP_GetIspSharpenAttr(pipe,&pstIspShpAttr);
    qDebug()<<"shard value"<<pstIspShpAttr.bEnable<<pstIspShpAttr.u8SkinUmax<<pstIspShpAttr.u8SkinUmin;
    pstIspShpAttr.bEnable=HI_TRUE;
    pstIspShpAttr.u8SkinUmax=value;
     pstIspShpAttr.u8SkinVmax=value;
    HI_MPI_ISP_SetIspSharpenAttr(pipe,&pstIspShpAttr);
    HI_MPI_ISP_GetIspSharpenAttr(pipe,&pstIspShpAttr);
    qDebug()<<"shard value"<<pstIspShpAttr.bEnable<<pstIspShpAttr.u8SkinUmax<<pstIspShpAttr.u8SkinUmin;
}

void Image::on_horizontalSlider_2_valueChanged(int value)
{
   qDebug()<<"222222"<<value;
}

void Image::on_horizontalSlider_valueChanged(int value)
{

}

void Image::on_horizontalSlider_4_valueChanged(int value)
{
    qDebug()<<"AE value"<<value;
    HI_MPI_ISP_GetExposureAttr(pipe, &m_stExpAttr);
    m_stExpAttr.stManual.u32ExpTime = value;
    double tmp = value;
    tmp = tmp*8.6461 + 0.5;
    if(tmp<143800)
        tmp = 143800;
    m_stExpAttr.stAuto.u32ExpValue = (HI_U32)tmp;
    HI_MPI_ISP_SetExposureAttr(pipe, &m_stExpAttr);
}



void Image::on_horizontalSlider_5_valueChanged(int value)
{
     HI_MPI_ISP_GetWBAttr(pipe, &m_stWBAttr);
     m_stWBAttr.stManual.u16Rgain = value;
     m_stWBAttr.enOpType = OP_TYPE_MANUAL;
     qDebug()<<"m_stWBAttr"<<m_stWBAttr.enOpType;

     HI_MPI_ISP_SetWBAttr(pipe, &m_stWBAttr);
}

void Image::on_horizontalSlider_6_valueChanged(int value)
{

    HI_MPI_ISP_GetWBAttr(pipe, &m_stWBAttr);
    m_stWBAttr.stManual.u16Bgain = value;
    m_stWBAttr.enOpType = OP_TYPE_MANUAL;
    qDebug()<<"m_stWBAttr"<<m_stWBAttr.enOpType;

    HI_MPI_ISP_SetWBAttr(pipe, &m_stWBAttr);
}
